package com.qiguliuxing.dts.db.dao.ex;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.qiguliuxing.dts.db.domain.DtsOrder;

public interface OrderMapper {
	
	int updateWithOptimisticLocker(@Param("lastUpdateTime") LocalDateTime lastUpdateTime,
			@Param("order") DtsOrder order);
	
	/**
	 * 根据条件获取入驻店铺的订单
	 * @param userId
	 * @param orderSn
	 * @param orderStatusSql
	 * @param orderBySql
	 * @param brandIdsSql
	 * @return
	 */
	List<DtsOrder> selectBrandOrdersByExample(@Param("userId") Integer userId, @Param("orderSn") String orderSn,  @Param("fetchCode") String fetchCode, @Param("orderStatusSql") String orderStatusSql, @Param("orderBySql") String orderBySql,
			@Param("brandIdsSql") String brandIdsSql);

	/**
	 * 根据传入的商品Id,获取含有该商品的未支付订单数
	 * @param goodsId
	 * @param orderStatus
	 * @return
	 */
	Long selectUnpayOrderCnt(@Param("goodsId") Integer goodsId, @Param("orderStatus") Short orderStatus);

	List<DtsOrder> queryExpiredCommentOrder(Map<String, Object> paramsMap);

    List<DtsOrder> queryExpiredUnconfirmOrder(Map<String, Object> paramsMap);

    List<DtsOrder> queryUnpaidOrder(Map<String, Object> paramsMap);

	/**
	 * 获取某个商户的商品销售总额
	 * 已经下单且非退款成功的商品的总价格
	 * @param brandId
	 * @return
	 */
	Long merchantSalesTotal(@Param("brandId") Integer brandId);

	/**
	 * 获取某个商户的总订单量
	 * @param brandId
	 * @return
	 */
	Long merchantOrderCount(@Param("brandId") Integer brandId);

}